<?php echo $header; ?>
<div id="content">
    <div class="breadcrumb">
        <?php echo $this->breadCrumbs(); ?>
    </div>
    <?php if (isset($error_warning)) { ?>
    <div class="warning"><?php echo $error_warning; ?></div>
    <?php } ?>
    <?php if ($success) { ?>
    <div class="success"><?php echo $success; ?></div>
    <?php } ?>
    <div class="box">
        <div class="heading">
            <h1><img src="view/image/payment.png" alt="" /> <?php echo $_['heading_title']; ?></h1>
            <div class="buttons">
                <a href="<?php echo UA('sale/rechargeablecard/autocreate'); ?>" class="button"><?php echo $_['text_auto_add'] ; ?></a>
                <a href="<?php echo UA('sale/rechargeablecard/insert'); ?>" class="button"><?php echo $_['button_insert']; ?></a>
                <a onclick="document.getElementById('form').submit();" class="button"><?php echo $_['button_delete']; ?></a></div>
        </div>
        <div class="content">
            <form action="<?php echo UA('sale/rechargeablecard/delete'); ?>" method="post" enctype="multipart/form-data" id="form">
                <table class="list">
                    <thead>
                    <tr>
                        <td width="1" style="text-align: center;"><input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" /></td>
                        <td class="left">
                            <a <?php echo sort_url('c.cardNumber'); ?>><?php echo $_['rechargeablecard_number']; ?></a>
                        </td>
                        <td class="left">
                            <a <?php echo sort_url('c.cardCode'); ?>><?php echo $_['rechargeablecard_code']; ?></a>
                        </td>
                        <td class="left">
                            <a <?php echo sort_url('c.cardAmount'); ?>><?php echo $_['rechargeablecard_amount']; ?></a>
                        </td>
                        <td class="left">
                            <a <?php echo sort_url('c.cardStatus'); ?>><?php echo $_['rechargeablecard_status']; ?></a>
                        </td>
                        <td class="left">
                            <a <?php echo sort_url('c.cardCustomer'); ?>><?php echo $_['rechargeablecard_customer']; ?></a>
                        </td>
                        <td class="left">
                            <a <?php echo sort_url('c.cardDate', true); ?>><?php echo $_['rechargeablecard_date']; ?></a>
                        </td>
                        <td class="right"><?php echo $_['rechargeablecard_action']; ?></td>
                    </tr>
                    </thead>
                    <tbody>
                    <?php if ($rechargeablecards) { ?>
                    <?php foreach ($rechargeablecards as $rechargeablecard) { ?>
                    <tr>
                        <td style="text-align: center;">
                            <input type="checkbox" name="selected[]" value="<?php echo $rechargeablecard['cardNumber']; ?>" />
                        </td>
                        <td class="left"><?php echo $rechargeablecard['cardNumber']; ?></td>
                        <td class="left"><?php echo $rechargeablecard['cardCode']?></td>
                        <td class="left"><?php echo $rechargeablecard['cardAmount']; ?></td>

                        <?php if($rechargeablecard['cardStatus']==1) { ?>
                        <td class="left"><?php echo $_['card_disabled']; ?></td>
                        <?php  }else { ?>
                        <td class="left"><?php echo $_['card_enabled']; ?></td>
                        <?php  }?>

                        <td class="left"><?php echo $rechargeablecard['cardCustomer']; ?></td>
                        <td class="left"><?php echo $rechargeablecard['cardDate']; ?></td>
                        <td class="right">
                            <?php foreach ($rechargeablecard['action'] as $action) { ?>
                            [ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
                            <?php } ?></td>
                    </tr>
                    <?php } ?>
                    <?php } else { ?>
                    <tr>
                        <td class="center" colspan="9"><?php echo $_['text_no_results']; ?></td>
                    </tr>
                    <?php } ?>
                    </tbody>
                </table>
            </form>
            <div class="pagination"><?php echo $pagination; ?></div>
        </div>
    </div>
</div>

<script type="text/javascript"><!--
    function sendVoucher(voucher_id) {
        $.ajax({
            url: '<?php echo UA('sale/rechargeablecard/update'); ?>&cardNumber=' + cardNumber,
                type: 'post',
                dataType: 'json',
                beforeSend: function() {
            $('.success, .warning').remove();
            $('.box').before('<div class="attention"><img src="view/image/loading.gif" alt="" /> <?php echo $_['text_wait']; ?></div>');
        },
        complete: function() {
            $('.attention').remove();
        },
        success: function(json) {
            if (json['error']) {
                $('.box').before('<div class="warning">' + json['error'] + '</div>');
            }

            if (json['success']) {
                $('.box').before('<div class="success">' + json['success'] + '</div>');
            }
        }
    });
    }
    //--></script>
<?php echo $footer; ?>